<template>
  <div class="list-item">
    <router-link
      :to="{
        path: '/detail',
        query: {
          id: data.id,
          field: 'food',
        },
      }"
    >
      <div class="img">
        <img :src="data.img" alt="" />
      </div>
      <div class="img-introduce">
        <p class="name">{{ data.name }}</p>
        <p class="stars-score">
          <stars :starNum="Number(data.star)"></stars>
          <span class="score">￥{{ data.default_price }}</span>
        </p>
        <p class="keyword">
          <span class="recom">{{ data.keyword }}</span>
        </p>
        <p class="others">
          <span class="field">{{ data.field }}</span>
          <span class="city_name">{{ data.city_name }}</span>
        </p>
      </div>
    </router-link>
  </div>
</template>

<script>
import stars from '../Sub/Star.vue';
export default {
  name: 'ListItem',
  props: {
    data: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  components: {
    stars,
  },
};
</script>

<style lang="scss" scoped>
.list-item {
  height: 1rem;
  background-color: #fff;
  padding: 0.1rem;
  margin-top: 0.01rem;
  a {
    display: flex;
    width: 3.55rem;
    height: 1rem;
    .img {
      width: 1rem;
      height: 1rem;
      padding-right: 0.05rem;
      img {
        height: 100%;
      }
    }
    .img-introduce {
      display: flex;
      width: 2.5rem;
      flex-direction: column;
      justify-content: space-between;
      .name {
        font-size: 0.18rem;
        width: 100%;
        font-weight: bold;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .stars-score {
        display: flex;
        width: 100%;
        .score {
          font-size: 0.18rem;
        }
      }
      .keyword {
        font-size: 0.16rem;
        color: #ffc300;
        width: 100%;
        white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
      }
      .others {
        display: flex;
        width: 100%;
        justify-content: space-between;
        font-size: 0.16rem;
        font-weight: bold;
      }
    }
  }
}
</style>
